<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ page import="com.utbm.lo54.entity.Course"%>
<%@ page import="com.utbm.lo54.entity.Location"%>
<%@ page import="com.utbm.lo54.entity.Session"%>
<%@ page import="java.util.Hashtable"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel=stylesheet type="text/css" href="design.css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Sessions List</title>
</head>
<body>
<br />
	<h1>
	<c:out value="${course.getCode()}" />
	: 
	<c:out value="${course.getTitle()}" /></h1>

	<table border="1">
		<tr>
			<TH>Start</TH>
			<TH>End</TH>
			<TH>Location</TH>
			<TH>Subscribe</TH>
		</tr>
		<c:forEach var="session" items="${sessions}">
			<c:set var="sessionId">${session.getId()}</c:set>
			<c:set var="locationId">${session.getLocationId()}</c:set>
			<tr>
				<td><c:out value="${session.getStartDate()}" /></td>
				<td><c:out value="${session.getEndDate()}" /></td>
				<td>				
				<% Hashtable<Long,Location> locations= (Hashtable<Long,Location>)request.getAttribute("locations");
				out.println(locations.get((Long.parseLong((String)pageContext.getAttribute("locationId")))).getCity());
				%>
				<td>
					<a href="http://localhost:8080/LO54_Project/InscriptionServlet?sessionid=${sessionId}">Subscribe</a>
					
				</td>

			</tr>

		</c:forEach>
	</table>
</body>
</html>